#!/usr/bin/python
'''This module shows how python communicate with an XML file in general

    @param xmlfilename

Finally this module should be a class which can be called be other
Python programs. And its return Value should be design to suite 
real world uses.'''

import xml.parsers.expat
import sys

def readXmlFile(file):
    p = xml.parsers.expat.ParserCreate()
    p.StartElementHandler = start_element
    p.EndElementHandler = end_element
    p.CharacterDataHandler = char_data
    p.ParseFile(file)
    print(p.returns_unicode)

def start_element(name, attrs):
    print 'Start element:', name, attrs
def end_element(name):
    print 'End element:', name
def char_data(data):
    print 'Character data:', repr(data)

if __name__=="__main__":
    if len(sys.argv) < 2:
        print("Please give a xml file to parse")
    else:
        for arg in sys.argv:
            readXmlFile(arg)
